package com.bot.nft.module.dc.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.domain.vo.DcSellInfoVo;
import com.bot.nft.module.dc.service.IDcSellInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author RenXiaoZheng
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/sell")
public class DcSellInfoController {

    @Resource
    IDcSellInfoService dcSellService;

    //分页查询寄售藏品信息
    @RequestMapping("/{pageNo}/{pageSize}/queryDcSell.do")
    public CommonResult<Page> selectDcBill(@RequestBody String keword, @PathVariable("pageNo") Integer pageNo, @PathVariable("pageSize") Integer pageSize) {
        Page<DcSellInfoVo> dcSellInfoVoPageInfo = dcSellService.queryDcSellInfo(keword, pageNo, pageSize);
        CommonResult<Page> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcSellInfoVoPageInfo)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcSellInfoVoPageInfo);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

    //查看寄售藏品信息
    @RequestMapping("/getDcSell.do")
    public CommonResult<DcSellInfoVo> getDcSell(@RequestParam("id") String id) {
        //调用接口
        DcSellInfoVo dcSellInfo = dcSellService.getDcSellInfo(id);
        CommonResult<DcSellInfoVo> commonResult = new CommonResult<>();
        if (ObjectUtil.isNotNull(dcSellInfo)) {
            commonResult.setMsg("操作成功");
            commonResult.setCode(200);
            commonResult.setData(dcSellInfo);
        } else {
            commonResult.setMsg("操作失败");
            commonResult.setCode(500);
        }
        return commonResult;
    }

}
